
#include <cppunit/config/SourcePrefix.h>

#include "TestPKBBitMapForStarRelation.h"
#include "PKB.h"
#include <iostream>
#include <string>

void PKBBitMapForStarRelationTest::setUp(){
}

void PKBBitMapForStarRelationTest::tearDown(){
}

void PKBBitMapForStarRelationTest::testSetStarBitMap(){
/*********************************
    ety c1 c2 c3 c4
 ety 0  0  0  0  0
 p1  0  0  1  1  1
 p2  0  0  0  1  1
 p3  0  0  0  0  1
 p4  0  0  0  0  0

 parent*(1,2)
 parent*(1,3)
 parent*(1,4)
 parent*(2,3)
 parent*(2,4)
 parent*(3,4)
**********************************/
	PKB::initializeInstance();
	PKB* myPkb = PKB::getInstance();
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStarBitMapSet());
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStarBitMapSet());
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallStarBitMapSet());
	vector<vector<bool>> sampleBitMap;
	for (int i = 0 ; i < 5; i++){
		vector<bool> temp;
		temp.clear();
		if (i==0 || i==4 ){
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(false);
		}else if(i==1){
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(true);
			temp.push_back(true);
			temp.push_back(true);
		}else if(i==2){
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(true);
			temp.push_back(true);
		}else{
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(false);
			temp.push_back(true);
	    }
		sampleBitMap.push_back(temp);
	}

	myPkb->setParentStarBitMap(sampleBitMap);
	myPkb->setFollowStarBitMap(sampleBitMap);
	myPkb->setCallStarBitMap(sampleBitMap);

	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStarBitMapSet());
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStarBitMapSet());
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallStarBitMapSet());

	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStar(1,2));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStar(1,3));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStar(1,4));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStar(2,3));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStar(2,4));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isParentStar(3,4));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(1,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(2,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(2,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(3,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(3,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(3,3));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(4,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(4,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isParentStar(4,3));

	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStar(1,2));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStar(1,3));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStar(1,4));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStar(2,3));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStar(2,4));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isFollowStar(3,4));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(1,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(2,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(2,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(3,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(3,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(3,3));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(4,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(4,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isFollowStar(4,3));

	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallsStar(1,2));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallsStar(1,3));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallsStar(1,4));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallsStar(2,3));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallsStar(2,4));
	CPPUNIT_ASSERT_EQUAL(true, myPkb->isCallsStar(3,4));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(1,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(2,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(2,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(3,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(3,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(3,3));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(4,1));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(4,2));
	CPPUNIT_ASSERT_EQUAL(false, myPkb->isCallsStar(4,3));

}





